import java.util.*;
public class Solution {
    public static void main(String[] args) {
        System.out.println(trans("This is a sample",16));
    }
    public static String trans(String s, int n) {
        String ans = "";
        String tmps = "";
        for(int i=n-1 ; i>=0 ;i--){
            char ch=s.charAt(i);
            if( !( ch == ' ') ){
                if( Character.isLowerCase(ch)){
                    tmps = String.valueOf(Character.toUpperCase(ch)).concat(tmps);
                }else if(Character.isUpperCase(ch)) {
                    tmps = String.valueOf(Character.toLowerCase(ch)).concat(tmps);
                }
            }else{
                ans =ans.concat(tmps.concat(" ")) ;
                tmps = "";
            }
        }
        ans = ans.concat(tmps);
        return ans;
    }
}